package com.itheima.d5_resource;

import java.io.*;

/*
     目标：掌握释放资源的方式：try-with-resource
 */
public class Test3 {
    public static void main(String[] args)  {
        try(  FileInputStream f = new FileInputStream("C:/Users/86156/Desktop/Snipaste_2024-10-27_16-58-31.png");
              FileOutputStream f2 = new FileOutputStream("yuanzhikong.png");){
            int t;
            byte[] bytes = new byte[1024];

            while ((t=f.read(bytes))!=-1){
                f2.write(bytes);
            }

        }catch (Exception e){
            e.printStackTrace();
        }


    }
}
